package com.beiben.ability.people.controller;

import java.util.List;
import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.beiben.ability.people.domain.Details;
import com.beiben.ability.people.service.IDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试详情Controller
 * 
 * @author dulei
 * @date 2020-08-26
 */
@RestController
@RequestMapping("/ability/details")
public class DetailsController extends BaseController
{
    @Autowired
    private IDetailsService detailsService;

    /**
     * 查询考试详情列表
     */
    @PreAuthorize("@ss.hasPermi('ability:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(Details details)
    {
        startPage();
        List<Details> list = detailsService.selectDetailsList(details);
        return getDataTable(list);
    }

    /**
     * 导出考试详情列表
     */
    @PreAuthorize("@ss.hasPermi('ability:details:export')")
    @Log(title = "考试详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Details details)
    {
        List<Details> list = detailsService.selectDetailsList(details);
        ExcelUtil<Details> util = new ExcelUtil<Details>(Details.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取考试详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('ability:details:query')")
    @GetMapping(value = "/{detailsId}")
    public AjaxResult getInfo(@PathVariable("detailsId") Long detailsId)
    {
        return AjaxResult.success(detailsService.selectDetailsById(detailsId));
    }

    /**
     * 新增考试详情
     */
    @PreAuthorize("@ss.hasPermi('ability:details:add')")
    @Log(title = "考试详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Details details)
    {
        return toAjax(detailsService.insertDetails(details));
    }

    /**
     * 修改考试详情
     */
    @PreAuthorize("@ss.hasPermi('ability:details:edit')")
    @Log(title = "考试详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Details details)
    {
        return toAjax(detailsService.updateDetails(details));
    }

    /**
     * 删除考试详情
     */
    @PreAuthorize("@ss.hasPermi('ability:details:remove')")
    @Log(title = "考试详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailsIds}")
    public AjaxResult remove(@PathVariable Long[] detailsIds)
    {
        return toAjax(detailsService.deleteDetailsByIds(detailsIds));
    }


    /**
     * 获取未录入人员信息
     */
    @PreAuthorize("@ss.hasPermi('ability:details:query')")
    @PostMapping(value = "/users/")
    public AjaxResult getUsersInfo(@RequestBody Details details)
    {
        return AjaxResult.success(detailsService.selectUsersByRecordId(details));
    }
}
